{extend name="public/base" /} {block name="body"}
<div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('web/index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li>
			<strong>职位管理</strong>
		</li>
	</ol>
</div>
<div class="ibox float-e-margins">
	{include file="employee/top"}
	<div class="ibox-content">
		<div class="row">
			<div class="col-sm-12">
				<div style="width:240px">
						<a href="#" onclick="add_zhiwei()" class="btn btn-xs btn-primary">添加</a>
				</div>
			</div>
		</div>
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">   
                            	<th>id</th>
                                <th>职位名称</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="list">
                        	{volist name="list" id='ad'}
                        	<tr>
                        		<td>{$ad.id}</td>                       		
                        		<td width="30%">{$ad.name}</td>
                        		<td>
                        			<a href="{:url('auth',['id'=>$ad.id])}" class="btn btn-success bnt-sm">
										<i class="fa fa-key"></i> 权限分配</a>&nbsp;&nbsp;
                        			<a href="#" onclick="edit_zhiwei({$ad.id},'{$ad.name}')" class="btn btn-primary bnt-sm">
										<i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp; 
									{if condition="$vo.id neq 1"}
									<a href="{:url('deletezw',['id'=>$ad.id])}" class="btn btn-danger bnt-sm ajax-delete">
										<i class="fa fa-trash-o"></i> 删除</a>
									{/if}
                        		</td>
                        	</tr>
                        	{/volist}
                        </tbody>
                    </table>
                </div>
            </div>
            </div>
</div>
{/block} {block name="script"}
<script src="__LIB__/datepicker/WdatePicker.js"></script>
<script>
	function edit_zhiwei(id,name){
	var html='<div class="form-group" id="add_form">'+
			'<label class="col-sm-3 control-label">职位名称：</label>'+
			'<div class="input-group col-sm-6">'+
				'<input type="text" id="zw_name2" value="'+name+'" class="form-control" />'+
				'<input type="hidden" id="zw_id2" value="'+id+'" class="form-control" />'+
			'<span id="error_tips" style="color: red;display: none;">请输入职位名</span></div></div>';
		var index=layer.open({
		  title: '修改职位',
		  zIndex :"edit_zhiwei",
	 	  area: ['600px', '180px'] ,
		  content: html,
		  btn: ['确定']
		  ,yes: function(index, layero){
		    //按钮【按钮一】的回调
		    var name=$("#zw_name2").val();
		    var id=$("#zw_id2").val();
		    if(name==""){
		    	$("#error_tips").show();
		    	return false;
		    }else{
		    	$.ajax({
					url:'editzw',
					data:{name:name,id:id},
					type:"post",
					success: function(data) {
						layer.close(index);
						layer.msg(data.msg);
						window.location="zhiwei";
					}
				})
		    	
		    }
		  }
		});

}
function add_zhiwei(){
	var html='<div class="form-group" id="add_form">'+
			'<label class="col-sm-3 control-label">职位名称：</label>'+
			'<div class="input-group col-sm-6">'+
				'<input type="text" id="zw_name" value="" class="form-control" />'+
			'<span id="error_tips" style="color: red;display: none;">请输入职位名</span></div></div>';
		var index=layer.open({
		  title: '添加职位',
		  zIndex :"add_zhiwei",
	 	  area: ['600px', '180px'] ,
		  content: html,
		  btn: ['确定']
		  ,yes: function(index, layero){
		    //按钮【按钮一】的回调
		    var name=$("#zw_name").val();
		    if(name==""){
		    	$("#error_tips").show();
		    	return false;
		    }else{
		    	$.ajax({
					url:'addzw',
					data:{name:name},
					type:"post",
					success: function(data) {
						layer.close(index);
						layer.msg(data.msg);
						window.location="zhiwei";
					}
				})
		    	
		    }
		  }
		});

}

</script>
<script>
	//顶部导航
	$("#li-bar-zhiwei").addClass("active");
</script>
<style>
.bank{
	width: 150px;
    height:30px;
    text-align:center;
    border-radius:5px;
}
</style>
{/block}